﻿using System;
using System.Collections.Generic;
using System.Text;
using Castle.ActiveRecord;
using Castle.Components.Validator;
using MiragePWF.NH.Validation;
using Wolfut.MirageEE.Kernal.Common;
using Wolfut.MirageEE.Domain.CommonUtilities;

namespace Wolfut.MirageEE.Domain.Procurement
{
    /// <summary>
    /// 费用支出信息
    /// </summary>
    /// <remarks>
    /// Author: Bruce
    /// Date: 2009-03-14
    /// </remarks>
    [ActiveRecord("EXPENSE_BILLS")]
    public class ExpenseBill : PersistentObjectWithGuid
    {

        #region 费用支出单编号
        private string expenseBillCode = string.Empty;
        /// <summary>
        /// 费用支出单编号
        /// </summary>
        [Property("EXPENSE_BILL_CODE")]
        [ValidateIsUniqueInSameTransactionWithString(true, "数据库已经存在相同的费用支出单编号！")]
        [ValidateNonEmpty, ValidateLength(0, 100, "费用支出单编号超长！")]
        public virtual string ExpenseBillCode
        {
            get { return expenseBillCode; }
            set { expenseBillCode = value; }
        }
        #endregion

        #region 供应商或者客户
        private string supplierOrCustomerCode = string.Empty;

        /// <summary>
        /// 供应商或者客户
        /// </summary>
        [Property("SUPPLIER_CUSTOMER_CODE")]
        [ValidateLength(0, 100, "供应商或者客户超长")]
        public virtual string SupplierOrCustomerCode
        {
            get { return supplierOrCustomerCode; }
            set { supplierOrCustomerCode = value; }
        }
        #endregion

        #region 币别代码
        private string currencyCode = string.Empty;

        /// <summary>
        /// 币别代码
        /// </summary>
        [Property("CURRENCY_CODE")]
        [ValidateLength(0, 40, "币别代码超长！")]
        public virtual string CurrencyCode
        {
            get
            {
                return currencyCode;
            }
            set
            {
                currencyCode = value;
            }
        }
        #endregion

        #region 备注
        private string remark;
        /// <summary>
        /// 备注
        /// </summary>
        [Property("REMARKS")]
        [ValidateLength(0, 2000, "备注超长！")]
        public virtual string Remark
        {
            get
            {
                return remark;
            }
            set
            {
                remark = value;
            }
        }
        #endregion

        #region 项目
        private string projectID = string.Empty;
        /// <summary>
        /// 项目
        /// </summary>
        [Property("PROJECTS_ID")]
        [ValidateLength(0, 40, "项目ID超长")]
        public virtual string ProjectID
        {
            get { return projectID; }
            set { projectID = value; }
        }
        #endregion

        #region 经办人
        private string operators = string.Empty;

        /// <summary>
        /// 经办人
        /// </summary>
        [Property("OPERATOR")]
        [ValidateLength(0, 40, "经办人超长！")]
        public virtual string Operator
        {
            get
            {
                return operators;
            }
            set
            {
                operators = value;
            }
        }
        #endregion        

        #region 供应商发票号
        private string inVoiceNo = string.Empty;

        /// <summary>
        /// 供应商发票号
        /// </summary>
        [Property("SUPPLIER_INVOICE_NUMBER")]
        [ValidateLength(0, 100, "供应商发票号超长！")]
        public virtual string InvoiceNo
        {
            get
            {
                return inVoiceNo;
            }
            set
            {
                inVoiceNo = value;
            }
        }
        #endregion

        #region 优惠折扣率
        /// <summary>
        /// 优惠折扣率
        /// </summary>
        [Property("GOODS_RETURNED_DISCOUNT")]
        [ValidateRange(0, 100, "优惠折扣率必须在0到100之间！")]
        public virtual decimal DiscountRate
        {
            get { return discountRate; }
            set { discountRate = value; }
        }
        private decimal discountRate;
        #endregion

        #region 日期
        private DateTime billDate;
        /// <summary>
        /// 日期
        /// </summary>
        [Property("BILL_DATE")]
        public virtual DateTime BillDate
        {
            get { return billDate; }
            set { billDate = value; }
        }
        #endregion        

        #region 付款账户
        private string paymentAccount = string.Empty;

        /// <summary>
        /// 接收退款的账户
        /// </summary>
        [Property("PAYMENT_ACCOUNT")]
        [ValidateLength(0, 100, "付款账户超长！")]
        public virtual string PaymentAccount
        {
            get
            {
                return paymentAccount;
            }
            set
            {
                paymentAccount = value;
            }
        }
        #endregion

        #region 本次付款
        /// <summary>
        /// 本次付款
        /// </summary>
        [Property("CURRENT_PAYMENT")]
        public virtual decimal CurrentPayment
        {
            get { return currentPayment; }
            set { currentPayment = value; }
        }
        private decimal currentPayment;
        #endregion

        #region 付款状态
        private PayState paymentState = PayState.NoPay;

        /// <summary>
        /// 付款状态
        /// </summary>
        [Property("PAYMENT_STATE")]
        public virtual PayState PaymentState
        {
            get
            {
                return paymentState;
            }
            set
            {
                paymentState = value;
            }
        }
        #endregion        

        #region 账期
        [Property("CLOSING_PERIOD")]
        [ValidateRange(0, int.MaxValue, "不合法的帐期！")]
        public virtual int ClosingPeriod
        {
            get { return closingPeriod; }
            set { closingPeriod = value; }
        }

        private int closingPeriod;
        #endregion        

        #region 制单人
        private string orderCreatedBy = string.Empty;

        /// <summary>
        /// 制单人
        /// </summary>
        [Property("PRODUCER_BY")]
        [ValidateLength(0, 40, "制单人超长！")]
        public virtual string OrderCreatedBy
        {
            get
            {
                return orderCreatedBy;
            }
            set
            {
                orderCreatedBy = value;
            }
        }
        #endregion

        #region 凭证号
        private string voucherNo = string.Empty;

        /// <summary>
        /// 凭证号
        /// </summary>
        [Property("VOUCHER_NO")]
        [ValidateLength(0, 100, "凭证号超长！")]
        public virtual string VoucherNo
        {
            get
            {
                return voucherNo;
            }
            set
            {
                voucherNo = value;
            }
        }
        #endregion

        #region 逻辑删除
        private Boolean isDeleted;
        [Property("IS_DELETED")]
        public virtual Boolean IsDeleted
        {
            get
            {
                return isDeleted;
            }
            set
            {
                isDeleted = value;
            }
        }
        #endregion

    }
}
